function getDeepObj(map, key = "") {
    if (key.indexOf(".") < 0) {
        map[key] = map[key] || {}
        return map[key]
    }
    let index = key.indexOf(".")
    let ck = key.substring(0, index);
    let nk = key.substring(index + 1)
    map[ck] = map[ck] || {}
    return getDeepObj(map[ck], nk)
}

function setDeepObjectValue(map, key = '', val = {}) {
    if (key.indexOf(".") < 0) {
        map[key] = val
        return
    }
    let index = key.indexOf(".")
    let ck = key.substring(0, index);
    let nk = key.substring(index + 1)
    map[ck] = map[ck] || {}
    return setDeepObjectValue(map[ck], nk,val);
}

function getConfigByKey(modelConfigMap, key = '') {
    return getDeepObj(modelConfigMap, key);
}

function saveConfigByKey(modelConfigMap, key = '', data) {
    return setDeepObjectValue(modelConfigMap, key, data)
}

const modelConfigMapTools = {
    getConfigByKey,
    saveConfigByKey
};
export default modelConfigMapTools